﻿using System;
using c2iGMailNotifier.Messaging;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Messaging;

namespace c2iGMailNotifier.ViewModel
{
    /// <summary>
    /// This class contains properties that a View can data bind to.
    /// <para>
    /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
    /// </para>
    /// <para>
    /// You can also use Blend to data bind with the tool's support.
    /// </para>
    /// <para>
    /// See http://www.galasoft.ch/mvvm/getstarted
    /// </para>
    /// </summary>
    public class ToolbarViewModel : ViewModelBase
    {
        /// <summary>
        /// Initializes a new instance of the ToolbarViewModel class.
        /// </summary>
        public ToolbarViewModel()
        {
            if (IsInDesignMode)
                this.LastUpdateDate = DateTime.Now;
            else
            {
                Messenger.Default.Register(this, delegate(RefreshDoneMessage message)
                                                     {
                                                         this.LastUpdateDate = message.LastUpdateDate;
                                                     });
            }
        }

        #region LastUpdateDate Property

        /// <summary>
        /// The <see cref="LastUpdateDate" /> property's name.
        /// </summary>
        public const string LastUpdateDatePropertyName = "LastUpdateDate";

        private System.DateTime _lastUpdateDate;

        public System.DateTime LastUpdateDate
        {
            get { return this._lastUpdateDate; }

            private set
            {
                if (this._lastUpdateDate == value) return;

                this._lastUpdateDate = value;
                RaisePropertyChanged(LastUpdateDatePropertyName);
            }
        }

        #endregion

    }
}